package com.huike.web.controller.rule;

import com.huike.clues.domain.TbRulePool;
import com.huike.clues.domain.dto.TbActivityDTO;
import com.huike.clues.domain.dto.TbRulePoolDTO;
import com.huike.clues.service.TbRulePoolService;
import com.huike.common.core.domain.AjaxResult;
import com.huike.task.task.RemindAndRecoveryTask;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.weaver.loadtime.Aj;
import org.springframework.web.bind.annotation.*;

/**ZhouYang
 * @Description 线索或商机池规则相关接口
 * @Date 2023-10-10
 */
@RestController
@Slf4j
@RequiredArgsConstructor
@Api(tags = "线索或商机池规则相关接口")
@RequestMapping("/rule/pool")
public class TbRulePoolController {

    private final TbRulePoolService tbRulePoolService;

    private final RemindAndRecoveryTask remindAndRecoveryTask;


    /**
     *查询线索、商机规则
     * @param type
     * @return
     */
    @ApiOperation("获取信息:线索=0,商机=1")
    @GetMapping("{type}")
    public AjaxResult getInfo(@PathVariable String type){
        log.info("开始执行:获取信息:线索=0,商机=1:{}",type);
        TbRulePool tbRulePool = tbRulePoolService.selectTbRulePoolType(type);
        return AjaxResult.success(tbRulePool);
    }


    /**
     *处理修改规则方法
     * @param tbRulePoolDTO
     * @return
     */
    @ApiOperation("修改规则接口")
    @PutMapping ()
    public AjaxResult updateTbRulePool(@RequestBody TbRulePoolDTO tbRulePoolDTO){

        log.info("开始执行修改规则:{}",tbRulePoolDTO);
        tbRulePoolService.updateTbRulePool(tbRulePoolDTO);
        remindAndRecoveryTask.updateRule();
        return AjaxResult.success();
    }
}
